home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol045 / bullet4 < prev    next >
Encoding:
Text File  |  1987-01-11  |  9.4 KB  |  181 lines

  1.  
  2.               XMODEM File Transfer Protocol
  3.  
  4.                     By Larry Jordan
  5.  
  6. When transferring files between computers using the telephone
  7. system, there is always the chance that electrical noise will
  8. result in data transmission errors. To ensure proper transfer of
  9. files it is necessary to detect data transmission errors and to
  10. retransmit data that contains errors. Most people think that
  11. asynchronous parity error detection provides that capability. It
  12. does not. Parity error detection does tell you when a data
  13. transfer error has occurred, but it is up to you to retransmit
  14. the data to correct errors. The problem is that parity error
  15. detection is not actually performed by most IBM PC communication
  16. packages. If a package does perform the error detection, it may
  17. not inform you of errors in such a way that you know to
  18. immediately retransmit the data. ASCOM, for example, places an
  19. asterisk in a file where parity errors are detected, but you
  20. may not realize the errors occurred until long after the file is
  21. transferred. To ensure "error-free" data transfer you need a
  22. protocol file transfer technique. Andrew Fluegelman has added
  23. such a technique to PC-TALK.III called the XMODEM protocol.
  24.  
  25. A protocol is a set of rules and conventions that apply to a
  26. specific area of communications that allow participants to
  27. properly communicate regardless of the hardware brand or software
  28. package being used. The protocol file transfer is a set of rules
  29. for transferring files which specifies a set of ASCII handshaking
  30. characters and the sequence of handshaking required to perform
  31. certain file transfer functions. Protocol handshaking signals
  32. allow communication software to transfer text, data and machine
  33. code files, and to perform sophisticated error-checking. The
  34. handicap in using protocol file transfer techniques is that the
  35. computers on both ends of the communications link must be using
  36. compatible software; there is no standard that controls these
  37. protocols and almost all communication packages that have a
  38. protocol file transfer option use a protocol unique to that
  39. package. This means that a business or group of people must
  40. standardize its microcomputer communications software to take
  41. advantage of protocol transfers.
  42.  
  43. The Ward Christensen XMODEM protocol is one specific file
  44. transfer protocol that may become a default standard in personal
  45. communications because of its widespread use on  bulletin
  46. boards and because of its inclusion in low cost personal computer
  47. communication packages such as PC-TALK. It has not gained
  48. widespread acceptance in business communication packages partly
  49. because the protocol is public domain; most business
  50. communication package designers use unique protocols to force
  51. businesses to use their software on both ends of communication
  52. links. By providing you with this insight into protocol transfer
  53. and explaining in detail the operation of the XMODEM protocol, I
  54. hope to add momentum to the development of a "standard protocol"
  55. whether it be the XMODEM model or some other model. Users of
  56. communication software deserve a standard protocol that will
  57. allow them to use the technique with any microcomputer regardles
  58. of the software packages employed.
  59.  
  60. The XMODEM protocol is illustrated in Figure 1. As you can see
  61. from that figure, XMODEM does not begin the transfer of data
  62. until the receiving computer signals the transmitting computer
  63. that it is ready to receive data. The Negative Acknowledge (NAK)
  64. character is used for this signal and is sent to the transmitting
  65. computer every 10 seconds until the file transfer begins. If the
  66. file transfer does not begin after 9 NAK's are sent, the process
  67. has to be manually restarted.
  68.  
  69. After a NAK is received, the transmitting computer uses a Start
  70. of Header (SOH) character and two block numbers (a true block
  71. number followed by a 1's complement of the number) to signal the
  72. start of a 128-byte block of data to be transferred then sends
  73. the block followed by an error-checking checksum.  The checksum
  74. is calculated by adding the ASCII values of each character in the
  75. 128 character block; the sum is then divided by 255 and the
  76. remainder is retained as the checksum.  After each block of data
  77. is transferred, the receiving computer computes its own checksum
  78. and compares the result to the checksum received from the
  79. transmitting computer.  If the two values are the same, the
  80. receiving computer sends an Acknowledge (ACK) character to tell
  81. the receiver to send the next sequential block.  If the two
  82. values are not the same, the receiving computer sends the
  83. transmitter an NAK to request a retransmission of the last block
  84. This retransmission process is repeated until the block of data
  85. is properly received or until 9 attempts have been made to
  86. transmit the block.  If the communications link is noisy,
  87. resulting in improper block transmission after 9 attempts, the
  88. file transfer is aborted.
  89.  
  90. XMODEM uses two block numbers at the start of each block to be
  91. sure the same block is not transmitted twice because of a
  92. handshake character loss during the transfer. The receiving
  93. computer checks the transmitted block to be sure that it is the
  94. one requested and blocks that are retransmitted by mistake are
  95. thrown away. When all data has been successfully transmitted, the
  96. transmitting computer sends the receiver an End of Transmission
  97. (EOT) character to indicate the end of file.
  98.  
  99. The XMODEM protocol offers the IBM PC several advantages over other
  100. protocols and file transfer methods. First, the protocol is in
  101. the public domain which makes it readily available for software
  102. designers to incorporate into a communications package. Second,
  103. the protocol is easy to implement using high level languages such
  104. as BASIC or Pascal. Third, the protocol only requires a 256-byte
  105. communication receive buffer which makes it attractive for IBM PC
  106. owners who only have 64K systems. Forth, the protocol allows a
  107. user to transfer non-ASCII 8-bit data files (i.e., COM, EXE and
  108. tokenized BASIC) between microcomputers because it calculates the
  109. end of a file based on file size and uses handshake signals to
  110. indicate the end of a file instead relying on an end of file
  111. marker character (control-Z) to terminate a file transfer.
  112. Fifth, XMODEM error-checking is superior to normal asynchronous
  113. parity error checking.  The parity method of error-checking is
  114. 95% effective if the software on the receiving end checks for
  115. parity errors.  XMODEM error-checking is 99.6% effective, and the
  116. software on the receiving end must check for errors.  Parity
  117. errors detected also do not result in automatic retransmission of
  118. the bad data; XMODEM detected errors result in data
  119. retransmission until no errors are detected or until 9
  120. retransmissions have been attempted.  Finally, the protocol is
  121. used by many CP/M bulletin boards and having the protocol in a
  122. communications package allows the IBM PC user to receive
  123. error-checked files from these bulletin boards.
  124.  
  125. Andrew Fluegelman has given the XMODEM protocol a real boost in
  126. the IBM PC world by including it in his package. He has also
  127. added significant power to the package by including the protocol
  128. Rumor has it that Don Withrow will soon add to the XMODEM
  129. momentum by adding it to his HOSTCOMM software package. Keep up
  130. the good work guys -- we will get a standard one way or the
  131. other!
  132.  
  133. [This article was derived from material contained in a book
  134. written by Larry Jordan and Bruce Churchill to be published this
  135. Summer by The Brady Company. The article will also be in the
  136. 5th issue of PC World magazine.]
  137.  
  138.  
  139.  
  140.              XMODEM Protocol File Transfer
  141.  
  142.  
  143. Receiving                                      Transmitting
  144. Computer                                         Computer
  145. Ready to                                         Ready to
  146. Receive                                          Transmit
  147.    |                                                |
  148.    |                                                |
  149.    |---------------------\NAK\--------------------->|
  150.    |                                                |
  151.    |<------/SOH/Blk #1/Blk #1/Good Data/CkSum/------|
  152.    |                                                |
  153.    |---------------------\ACK\--------------------->|
  154.    |                                                |
  155.    |<------/SOH/Blk #2/Blk #2/Good Data/CkSum/------|
  156.    |                                                |
  157.    |---------------------\ACK\--------------------->|
  158.    |                                                |
  159.    |<------/SOH/Blk #3/Blk #3/Garbled Data/CkSum/---|
  160.    |                                                |
  161.    |---------------------\NAK\--------------------->|
  162.    |                                                |
  163.    |<------/SOH/Blk #3/Blk #3/Good Data/CkSum/------|
  164.    |                                                |
  165.    |---------------------\ACK\--------------------->|
  166.    |                                                |
  167.    |<--------------------/EOT/----------------------|
  168.    |                                                |
  169.    |---------------------\ACK\--------------------->|
  170.    |                                                |
  171.    V                                                V
  172.  
  173.   File                                             File
  174. Receipt                                          Transmit
  175.   Ends                                             Ends
  176.  
  177.                            Figure 1
  178.  
  179.  
  180. -------------------------------------------------------------------
  181.